﻿@using ECG.Utility
@using ECG.WebUI.CustomHelpers
@model List<ECG.Common.ProductGoldenTimeListByCateDto>
<ul class="gt-listp clearfix">
    @*<img src="@string.Format("{0}/188x188/{1}", item.ImagePath, item.ImageName)" width="168" height="168" alt="@item.Name" />*@
    @{
        if (Model != null && Model.Count > 0)
        {
            var count = 0;
            foreach (var item in Model)
            {
                count++;
                var pDetailLink = Url.Action("Index", "ProductDetail", new { productId = item.Id, productName = StringUtil.RemoveSpecialCharactersVn(item.Name) });
                var percent = 0;
                percent = item.PromotionUnit != 0 ? item.PromotionUnit : item.PromotionPercent;

                string str;
                if (count == 4)
                {
                    count = 0;
                    str = "listp-item-last";
                }
                else
                {
                    str = "listp-item";
                }
                var NewPrice = item.Price;
                if (item.PromotionUnit != 0)
                {
                    NewPrice = item.Price - (item.Price * item.PromotionUnit) / 100;
                }
        <li class='@str'>
            <div class="listp-cell">
                <div class="gt-icon-sale">
                    <p>sale </p>
                    <span class="gt-promo">@percent</span><sup>%</sup>
                </div>
                <div class="listp-img">
                    <a href="@pDetailLink">
                        <img src="@string.Format("{0}/188x188/{1}", item.ImagePath, item.ImageName)" width="188" height="188" alt="@item.Name" class="img-loading"/>
                    </a>
                </div>
            </div>
            <div class="listp-txt clearfix">
                <div class="gt-Price">
                    @{
                if (item.PromotionUnit != 0)
                {
                        <p class="oldPrice">
                            @item.Price.ToString("##,###,###")
                            <span>VNĐ</span>
                        </p>
                }
                    }

                    <p class="newPrice">
                        @{
                            if (NewPrice!=0)
                            {
                                @NewPrice.ToString("##,###,###")
                            }
                            else
                            {
                                <span>0</span>
                            }
                        }

                        <span>VNĐ</span>
                    </p>
                </div>
                <div class="gt-buyp">
                    <span class="gt-iconView"></span>
                </div>
            </div>
            <h2>
                <a href="@pDetailLink">@item.Name</a>
            </h2>
        </li>
            }
        }
    }

</ul>
